package com.igeek.config.way1;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.w3c.dom.ls.LSOutput;

/**
 * TODO
 *
 * @author chh
 * @since 2024/5/20
 * BeanFactory
 *
 * 一种实现方式为：在实体类上加入注解@Component()以及在宁外一个类中加入@ComponentScan该类用于在获取容器时传入其对应的类信息
 **/
public class MyTest {
    public static void main(String[] args) {
        //获取IOC容器
        ApplicationContext ac=new AnnotationConfigApplicationContext(MyConfig.class);

        //获取bean实例
        Student stu=ac.getBean("student",Student.class);
        Student stu1=ac.getBean("student",Student.class);
        //使用bean实例
        stu.setAge(14);
        stu.setName("sjj");
        System.out.println(stu);
        System.out.println("该学生信息为："+stu.getName()+"   "+stu.getAge());
        System.out.println(stu==stu1);

    }





}
